import pymysql
conn = pymysql.Connect(host='127.0.0.1', user='root',password='199802',db='xuesheng',port=3306,charset='utf8')
print(conn, type(conn))
#创建游标对象
cursor = conn.cursor()
sql = 'create table if not exists test (name varchar(200),id int primary key)'
cursor.execute(sql)#执行
cursor.close()#关闭游标
conn.close()#关闭数据库连接